home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 14938 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: noc.netcom.net!news
  2. From: Tarang Deshpande <tarang@willows.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Nee help with a string and temp string
  5. Date: Mon, 15 Apr 1996 13:00:03 -0700
  6. Organization: NETCOM Network Operations
  7. Message-ID: <3172AAC3.2D5D@willows.com>
  8. References: <316C72CC.763A@cloudnet.com> <316DB246.74FB@willows.com> <829411539snz@genesis.demon.co.uk>
  9. NNTP-Posting-Host: daffy.willows.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0GoldB2 (Win95; I)
  14.  
  15. Lawrence Kirby wrote:
  16. > Wrong. strncpy() always writes exactly the number of characters you specify
  17. > to the target buffer. It does not guarantee that the result is a string i.e.
  18. > null character terminated and is an oddity in the standard string library.
  19. > In this case it simply corresponds to:
  20. >     Bcard[0] = 'B';
  21.  
  22. Lawrence is abolutly right I didn't look at the code carefully enough
  23. and read strncpy as strcpy even though I typed strncpy.  I use strncpy
  24. so rarely that I just had it in my head that is was strcpy.  However
  25. I still say the simplest, though costly, solution is to memset the
  26. buffer to 0.
  27.